package cn.imnaer.service.rest.view.model;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import cn.imnaer.service.persistence.model.ContributionImageItem;
import cn.imnaer.service.persistence.model.ScenicContribution;

public class ScenicContributionView {
	private String scenicId;
	private String contributionId;
	private int score;
    private String userId;
    private String name;
    private long createTime;
	private List<String> images=new ArrayList<>();
	private  String  text;
	    public String getScenicId() {
		return scenicId;
	}
	public void setScenicId(String scenicId) {
		this.scenicId = scenicId;
	}
	public String getContributionId() {
		return contributionId;
	}
	public void setContributionId(String contributionId) {
		this.contributionId = contributionId;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public long getCreateTime() {
		return createTime;
	}
	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}
	public List<String> getImages() {
		return images;
	}
	public void setImages(List<String> images) {
		this.images = images;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}

	public  static  ScenicContributionView valueOf(ScenicContribution  scenicContribution){
		ScenicContributionView  view=new ScenicContributionView();
	List<String> imageStrList = view.getImages();
		    BeanUtils.copyProperties(scenicContribution, view);
		 List<ContributionImageItem> contributeImages = scenicContribution.getItems();
		 if(contributeImages.size()>0){
		 ContributionImageItem imageItem = contributeImages.get(0);
		    view.setText(imageItem.getText());
		 }
		 for (ContributionImageItem contributionImageItem : contributeImages) {
			 imageStrList.add(contributionImageItem.getImage());
		}		 
		return  view;
	}
  public static   List<ScenicContributionView>	valueOfList(List<ScenicContribution> scenicContributions){
	  List<ScenicContributionView>  scenicContributionViewList=new ArrayList<>();
	  for (ScenicContribution scenicContribution : scenicContributions) {
	ScenicContributionView view = valueOf(scenicContribution);
	scenicContributionViewList.add(view);
	}
	 
	  
	  return scenicContributionViewList;
  }
  
}
